Timers are typically used by operating systems and application software to schedule activities. For example, an operating system kernel may use a timer to allow a plurality of user-level applications to time-share the resources of the system (e.g., the central processing unit (CPU)). An example of a timer used on a personal computer (PC) platform is the 8254 Programmable Interval Timer. This timer may be configured to issue interrupts after a specified interval or periodically.
Another example of a timer is the timestamp counter (TSC) used in the instruction set architecture (ISA) of the Intel® Pentium® 4 (referred to herein as the IA-32 ISA). The TSC is a 64-bit counter that is set to 0 following the hardware reset of the processor, and then incremented every processor clock cycle, even when the processor is halted by the HLT instruction. The TSC cannot be used to generate interrupts. It is a time reference only, useful to measure time intervals. The IA-32 ISA provides an instruction (RDTSC) to read the value of the TSC and an instruction (WRMSR) to write the TSC. When WRMSR is used to write the time-stamp counter, only the 32 low-order bits may be written; the high-order 32 bits are cleared to 0. Because of these writing restrictions, software generally cannot set the TSC forward nor set it backwards to an arbitrary value.
In multi-processor (MP) systems, the TSC is used to properly synchronize processors and schedule processes appropriately. At boot time, the values of the TSC on all processors are synchronized and most operating systems assume that the TSC then count at the same rate. If the TSC values drift between processors (e.g., if one processor counts at a different rate that the others), scheduling of processes by the operating system may be confused.